
{extend name='public/window' /}

{block name="content"}

<div class="layui-fluid">
    <div class="layui-card">

        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" action="" lay-filter="form">
            <div class="layui-tab layui-tab-brief">
                <ul class="layui-tab-title">
                    <li class="layui-this">设置</li>
                    
                </ul>
                <div class="layui-tab-content" style="margin-top: 20px;">

                    <div class="layui-tab-item layui-show">
                        
                        <div class="layui-form-item">
                            <label class="layui-form-label">选择模型：</label>
                            <div class="layui-input-inline input-custom-width">
                                <select name="modelid" id="model" lay-filter="model">
                                    <option value="0">请选择</option>
                                    {volist name="models" id="v"}
                                    <option value="{$v.id}">{$v.name}</option>
                                    {/volist}
                                </select>
                            </div>

                            <label class="layui-form-label">选择栏目：</label>
                            <div class="layui-input-inline input-custom-width">
                                <select name="cateid" id="cate" lay-filter="cate">
                                    <option value="0">请选择</option>
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-mid layui-word-aux"></div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">类型：</label>
                            <div class="layui-input-block input-custom-width">
                                <input type="text" name="type" value="" class="layui-input ">
                            </div>
                        </div>

                        <!-- <div class="layui-form-item">
                            <label class="layui-form-label">大类：</label>
                            <div class="layui-input-block input-custom-width">
                                <input type="text" name="dalei" value="" class="layui-input ">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">中类：</label>
                            <div class="layui-input-block input-custom-width">
                                <input type="text" name="zhonglei" value="" class="layui-input ">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">小类：</label>
                            <div class="layui-input-block input-custom-width">
                                <input type="text" name="xiaolei" value="" class="layui-input ">
                            </div>
                        </div> -->

                        <div class="layui-form-item">
                            <label class="layui-form-label">关键词：</label>
                            <div class="layui-input-block input-custom-width">
                                <input type="text" name="keyword" value="" class="layui-input ">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">城市：</label>
                            <div class="layui-input-block input-custom-width">
                                <input type="text" name="cityname" value="" class="layui-input ">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">数量：</label>
                            <div class="layui-input-block">
                                <input type="number" min="0" name="num" value="100" placeholder="" lay-verify="required" lay-vertype="tips" lay-reqtext="" autocomplete="off" class="layui-input ">
                            </div>
                        </div>

                        <div class="layui-form-mid layui-word-aux"></div>

                        
                    </div>

                    

                </div>

            </div>
                <div class="layui-form-item layui-layout-admin " style="width: 100%">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0px;text-align: center;">
                            <button class="layui-btn" lay-submit="" lay-filter="exe">执行</button>
                            <button type="reset" class="layui-btn layui-btn-primary">{:__('Reset')}</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
    layui.use(['element', 'form', 'jquery','lucky'], function () {
        var element = layui.element;
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;
        var lucky=layui.lucky;

        form.on('submit(exe)', function (data) {
            layer.msg('正在执行。。', { icon: 1, time: 0, shade: 0.3, anim: 4 });
            Execute("{:url('pull',['table'=>$Request.get.table])}",data.field);
            return false;
        });
        function Execute(url, data){
            $.post(url,data,function(res){
                layer.msg(res.msg, { icon: 1, time: 0, shade: 0.3, anim: 4 });
                if(res.code == 1){
                    data.num = res.data.num;
                    Execute(url,data);
                }else{
                    layer.msg(res.msg, { icon: 1, time: 1500, shade: 0.3, anim: 4 });
                    console.log(res);
                }
            });
        }

        form.on('select(model)', function(data) { 
            $("#cate").empty();
            $("#cate").append('<option value="0">请选择</option>');
            form.render("select");
            if(data.value != 0){
                $.get("{:url('admin/ArticleCate/ajaxGetCatesByModelid')}",{modelid:data.value},function(result){
                    if(result.code){
                        $.each(result.data,function(index,obj){
                            $("#cate").append('<option value="'+obj.id+'">'+obj.title_show+'</option>');
                        });
                        form.render("select");
                    }
                });
            }
        })
    })
</script>

{/block}

